<template>
  <div class="my-favorite">
    <div class="header">
      <div class="title">我的收藏</div>
      <!-- <div class="search">
        <el-input placeholder="请输入关键词"
          v-model="search" clearable size="small"/>
        <el-button type="primary" size="small">搜索</el-button>
      </div> -->
    </div>
    <div class="favorite-list">
      <GoodsList :goodsList="goodsList"/>
    </div>
  </div>
</template>

<script>
import GoodsList from './components/GoodsList.vue';
  export default {
    name: 'MyFavorite',
    components: {
      GoodsList
    },
    data(){
      return {
        search: '',
        goodsList: []
      }
    },
    methods: {
      getGoodList() {
        this.$axios.get(`/favorite/user/${this.$store.state.user.userId}`).then(res => {
          if (res.status === 200) {
            this.goodsList = res.data.data.records
          } else {
            this.$message.error('获取收藏列表失败')
          }
        })
      }
    },
    mounted() {
      this.getGoodList();
    }
  }
</script>

<style lang="scss" scoped>
.my-favorite {
  padding: 20px;
  width: 100%;
  .header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    .title {
      font-size: 1.2em;
      font-weight: bold;
    }
    .search {
      display: flex;
      align-items: center;
      .el-button {
        margin-left: 20px;
      }
    }
  }
  .favorite-list {
    margin-top: 20px;
  }
}
</style>